using STHPMS1.BLL.B_Serv;
using STHPMS1.ICore;
using STHPMS1.ICore.I_BLL;
using STHPMS1.ICore.I_Common;
using STHPMS1.ICore.I_Core;
using STHPMS1.ICore.I_Serv;

namespace STHPMS1.BLL.B_Core
{
	public class BllModule : DisposeObject//, IModule
	{
		public static void Init ()
		{
			System.Diagnostics.Debug.WriteLine ("BllModule");
			IBllFactory factory = new BllFactory ();
			IBllFacade facade = new BllFacade ();
            IKeyGenrateService idServ = new IdGenrateService();

			MyApp.Locator.AddBuilder<IObjectFactory> (() => factory, TypeStringDefinition.BLLFACTORY);
			MyApp.Locator.AddBuilder<IFacade> (() => facade, TypeStringDefinition.BLLFACADE);
			MyApp.Locator.AddBuilder<IBllFactory> (() => new BllFactory ());
			MyApp.Locator.AddBuilder<IBllFacade> (() => new BllFacade ());


            MyApp.Locator.AddBuilder<IKeyGenrateService>(() => idServ);
            MyApp.Locator.AddBuilder<IRoadDividedService>(() => new RoadDividedService());
            MyApp.Locator.AddBuilder<IDeflectionCalculateService>(() => new DeflectionCalculateService());
            
		}

		protected override void OnDispose ()
		{
			MyApp.Locator.RemoveBuidler<IObjectFactory> (TypeStringDefinition.BLLFACTORY);
			MyApp.Locator.RemoveBuidler<IFacade> (TypeStringDefinition.BLLFACADE);
			MyApp.Locator.RemoveBuidler<IBllFactory> ();
			MyApp.Locator.RemoveBuidler<IBllFacade> ();

            MyApp.Locator.RemoveBuidler<IdGenrateService>();
            MyApp.Locator.RemoveBuidler<IRoadDividedService>();
            MyApp.Locator.RemoveBuidler<IDeflectionCalculateService>();
		}
	}
}
